<? if(!defined('IN_TIPASK')) exit('Access Denied'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"><? $user=$this->user; $setting=$this->setting; ?><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Tipask's Control Panel</title>
        <meta http-equiv="Content-Type" content="text/html; charset=<?=TIPASK_CHARSET?>">
        <link media="all" type="text/css" href="css/common/admin/admincp.css" rel="stylesheet" />
        <script src="js/jquery.js" type="text/javascript"></script>
        <script src="js/admin.js" type="text/javascript"></script>
        <script src="js/calendar.js" type="text/javascript"></script>
    </head>

    <body>

        <div id="append">
        </div>

        <div class="container">
            <? if(isset($message)) { ?>            <? $type=isset($type)?$type:'correctmsg';  ?>            <div class="<?=$type?>"><p><?=$message?></p></div>
            <? } ?>            <h3>礼品列表 <a href="index.php?admin_gift/add<?=$setting['seo_suffix']?>" class="sgbtn">添加礼品</a><a href="index.php?admin_gift/addrange<?=$setting['seo_suffix']?>" class="sgbtn">礼品价格区间</a><a href="index.php?admin_gift/note<?=$setting['seo_suffix']?>" class="sgbtn">礼品公告</a><a href="index.php?admin_gift/log<?=$setting['seo_suffix']?>" class="sgbtn">礼品兑换日志</a></h3>
            <br />
            <div class="hastabmenu">
                <div class="tabcontentcur" id="srchuserdiv">
                    <form action="index.php?admin_gift/search<?=$setting['seo_suffix']?>" method="post">
                        <table width="100%">
                            <tr>
                                <td>价格范围:</td>
                                <td>
                                    <select name="pricerange">
                                        <option value="all">全部</option>
                                        
<? if(is_array($gift_range)) { foreach($gift_range as $key => $val) { ?>
                                        <option value="<?=$key?>-<?=$val?>"><?=$key?>-<?=$val?></option>
                                        
<? } } ?>
                                    </select>
                                </td>
                                <td>礼品名称:</td>
                                <td><input class="txt" name="giftname"></td>
                                <td rowspan="2"><input class="btn" type="submit" name="submit" value="提 交"></td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
            <br>
            <h4>[共 <?=$giftnum?> 个礼品]</h4>
            <div class="mainbox">
                <form name="userForm" action="index.php?admin_gift/remove<?=$setting['seo_suffix']?>" method="post">
                    <table class="datalist fixwidth" >
                        <tr>
                            <th><input class="checkbox" id="chkall" onclick="checkall('gid[]')" type="checkbox" name="chkall"><label for="chkall">全选</label></th>
                            <th>礼品图片</th>
                            <th>礼品名称</th>
                            <th>所需金币</th>
                            <th>礼品描述</th>
                            <th>更新时间</th>
                            <th>是否过期</th>
                            <th>操作</th>
                        </tr>
<? if(is_array($giftlist)) { foreach($giftlist as $gift) { ?>
                        <tr>
                            <td class="option"><input class="checkbox" type="checkbox" value="<?=$gift['id']?>" name="gid[]"></td>
                            <td><img src="<?=SITE_URL?><?=$gift['image']?>" width="80" height="80"/></td>
                            <td><strong><?=$gift['title']?></strong></td>
                            <td><?=$gift['credit']?></td>
                            <td><?=$gift['description']?></td>
                            <td><?=$gift['time']?></td>
                            <td><? if(!$gift['available']) { ?><font color="Red">是</font><? } else { ?>否<? } ?></td>
                            <td><a href="index.php?admin_gift/edit/<?=$gift['id']?><?=$setting['seo_suffix']?>">编辑</a></td>
                        </tr>
<? } } ?>
                        <tr class="nobg">
                            <td colspan="7" class="tdpage"><div class="pages"><?=$departstr?></div></td>
                        </tr>
                        <tr class="nobg">
                            <td colspan="7"><input class="btn" type="button" name="available" onclick="onavailable(0);" value="设为过期" />&nbsp;&nbsp;<input class="btn" type="button" name="available" onclick="onavailable(1);" value="设为可用" />&nbsp;&nbsp;<input class="btn" type="button" name="delete" onclick="ondelete();" value="删除" /></td>
                        </tr>

                    </table>
                </form>
            </div>
        </div>

    </body>
    <script type="text/javascript">
        function onavailable(type){
            if($("input[name='gid[]']:checked").length == 0){
                alert('你没有选择任何礼品！');
                return false;
            }
            document.userForm.action="index.php?admin_gift/available/"+type+"<?=$setting['seo_suffix']?>";
            document.userForm.submit();
        }
        function ondelete(){
            if($("input[name='gid[]']:checked").length == 0){
                alert('你没有选择任何礼品!');
                return false;
            }
            if(confirm('确认删除该礼品?此操作不可恢复!')==false){
                return false;
            }
            document.userForm.action="index.php?admin_gift/remove<?=$setting['seo_suffix']?>";
            document.userForm.submit();
        }
    </script>
</html>
